<%@ page import="java.util.Date" %><%--
  Created by IntelliJ IDEA.
  User: dailyblue
  Date: 2025/7/16
  Time: 09:10
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" isELIgnored="false" language="java" %>
<!--核心标签 核心标签是最常用的 JSTL标签-->
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
<html>
<head>
    <title>Title</title>
</head>
<body>
<%
    session.setAttribute("A", "aaaa");
    session.setAttribute("C", (int) (Math.random() * 100 + 1));
    String[] array = {"西安", "宝鸡", "渭南", "商洛", "汉中", "榆林"};
    session.setAttribute("D", array);
    session.setAttribute("E", new Date());
%>
<c:set value="bbbb" var="B" scope="session"></c:set>

${A}..${B}

<hr/>
<h3>单层if分支</h3>
<c:if test="${C>66}">
    ${C}大于66
</c:if>
<h3>if-else分支</h3>
<c:choose>
    <c:when test="${C>66}">
        ${C}大于66
    </c:when>
    <c:otherwise>
        ${C}小于66
    </c:otherwise>
</c:choose>
<h3>多层if分支</h3>
<c:choose>
    <c:when test="${C==100}">
        ${C}完美
    </c:when>
    <c:when test="${c>=85}">
        ${C}优秀
    </c:when>
    <c:when test="${C>=60}">
        ${C}及格
    </c:when>
    <c:otherwise>
        ${C}很差
    </c:otherwise>
</c:choose>
<hr/>
<h3>for循环</h3>
<c:forEach var="i" begin="1" end="10" step="1">
    <b>${i}&nbsp;&nbsp;&nbsp;&nbsp;</b>
</c:forEach>
<h3>foreach循环</h3>
<c:forEach var="e" items="${D}" varStatus="j">
    j:${j.count},e:${e}<br/>
</c:forEach>
<hr/>
<h3>格式化标签</h3>
<fmt:formatNumber var="num1" value="89.888888" pattern="##.##"/>
${num1}
<h4>原来的时间</h4>
${E}
<h4>格式化之后的时间</h4>
<fmt:formatDate value="${E}" var="E2" pattern="yyyy年MM月dd日 HH:mm:ss"/>
${E2}
</body>
</html>
